<!-- 2017-12-7 14:56:03 | 修改 木遥（微信:  http://marsgis.cn/weixin.html ） -->
<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0" />
    <meta name="apple-touch-fullscreen" content="yes" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="x5-fullscreen" content="true" />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
    <!-- 标题及搜索关键字 -->
    <meta name="keywords" content="火星科技,cesium,3D,GIS,marsgis,三维,地球,地图,开发,框架,系统,示例,资料,模型,离线,外包,合肥,安徽,中国" />
    <meta
      name="description"
      content="火星科技 合肥火星 合肥火星科技 合肥火星科技有限公司 leaflet leaflet框架 leaflet开发 cesium cesium开发 cesium框架 三维 地球 模型  gis marsgis 地图离线 地图开发 地图框架 地图外包 框架 开发 外包  地图离线 二维地图 三维地图 全景漫游 地理信息系统 云GIS 三维GIS GIS平台 WebGIS"
    />

    <link rel="shortcut icon" type="image/x-icon" href="http://mars3d.cn/favicon.ico" />
    <title>空中漫游 | Mars3D | 三维地图 | 火星科技 | 合肥火星科技有限公司</title>

    <script
      type="text/javascript"
      src="../lib/include-lib.js"
      libpath="../lib/"
      include="jquery,font-awesome,bootstrap,bootstrap-checkbox,jquery.range,layer,haoutil,turf,mars3d"
    ></script>

    <link href="css/style.css" rel="stylesheet" />
    <link href="css/divpoint.css" rel="stylesheet" />
    <style>
      .mp_table {
        width: 100%;
        border: #cde1de 1px solid;
        font-size: 12px;
        border-collapse: collapse;
        border-spacing: 0;
      }

      .mp_table tr td {
        padding: 5px 5px;
        text-align: left;
        border: #cde1de 1px solid;
      }

      .mp_table tr td:first-child {
        border-left: none;
      }

      .nametd {
        width: 40%;
      }

      .mp_head2 {
        width: 100%;
        height: 45px;
        line-height: 45px;
        text-align: center;
      }

      .dark .progress {
        margin: 0;
        background-color: #0b2931;
      }
    </style>
  </head>

  <body class="dark">
    <!--加载前进行操作提示，优化用户体验-->
    <div id="mask" class="signmask" onclick="removeMask()"></div>

    <div id="mars3dContainer" class="mars3d-container"></div>

    <!-- 信息 面板 -->
    <div class="infoview rightbottom" style="min-width: 200px">
      <table class="mp_table">
        <tr>
          <td class="nametd">总长度</td>
          <td id="td_alllength"></td>
        </tr>
        <tr>
          <td class="nametd">已漫游长度</td>
          <td id="td_length"></td>
        </tr>
        <tr>
          <td class="nametd">总时长</td>
          <td id="td_alltimes"></td>
        </tr>
        <tr>
          <td class="nametd">已漫游时间</td>
          <td id="td_times"></td>
        </tr>

        <tr>
          <td class="nametd">经度</td>
          <td id="td_jd"></td>
        </tr>
        <tr>
          <td class="nametd">经度</td>
          <td id="td_wd"></td>
        </tr>
        <tr>
          <td class="nametd">漫游高程</td>
          <td id="td_gd"></td>
        </tr>
        <tr>
          <td class="nametd">地面高程</td>
          <td id="td_dmhb"></td>
        </tr>
        <tr id="tr_ldgd">
          <td class="nametd">离地距离</td>
          <td id="td_ldgd"></td>
        </tr>

        <tr>
          <td colspan="2" style="width: 100%; text-align: center">
            <div class="progress">
              <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">0%</div>
            </div>
          </td>
        </tr>
      </table>
    </div>

    <script src="./js/common.js"></script>
    <script type="text/javascript">
      'use script' //开发环境建议开启严格模式

      var map
      var roamLine

      function initMap(options) {
        //合并属性参数，可覆盖config.json中的对应配置
        var mapOptions = mars3d.Util.merge(options, {})

        //创建三维地球场景
        map = new mars3d.Map('mars3dContainer', mapOptions)

        //创建矢量数据图层
        var graphicLayer = new mars3d.layer.GraphicLayer()
        map.addLayer(graphicLayer)

        //参数可以从 基础项目 飞行漫游功能界面操作后保存JSON
        roamLine = new mars3d.graphic.RoamLine({
          name: '空中漫游',
          timeField: 'datatime',
          positions: [
            { lng: 117.217898, lat: 31.80021, alt: 500, datatime: '2021/3/25 0:01:00' },
            { lng: 117.217535, lat: 31.815032, alt: 500, datatime: '2021/3/25 0:01:30' },
            { lng: 117.21596, lat: 31.853067, alt: 500, datatime: '2021/3/25 0:02:10' },
          ],
          camera: {
            type: 'dy',
            followedX: 50,
            followedZ: 10,
          },
          clockLoop: true, //是否循环播放
          interpolation: true, //setInterpolationOptions插值
        })
        graphicLayer.addGraphic(roamLine)

        //开始漫游
        roamLine.start()

        addDivPoint(roamLine.property)

        //显示基本信息，名称、总长、总时间
        $('#td_alltimes').html(haoutil.str.formatTime(roamLine.alltimes))
        $('#td_alllength').html(haoutil.str.formatLength(roamLine.alllen))

        roamLine.on(mars3d.EventType.change, (event) => {
          //面板显示相关信息
          showRealTimeInfo(event, roamLine.alltimes)
        })
      }

      //显示实时坐标和时间
      function showRealTimeInfo(params, _alltime) {
        if (params == null) {
          return
        }

        var val = Math.ceil((params.time * 100) / _alltime)
        if (val < 1) {
          val = 1
        }
        if (val > 100) {
          val = 100
        }

        $('.progress-bar')
          .css('width', val + '%')
          .attr('aria-valuenow', val)
          .html(val + '%')

        $('#td_jd').html(params.lng)
        $('#td_wd').html(params.lat)
        $('#td_gd').html(haoutil.str.formatLength(params.alt))

        $('#td_times').html(haoutil.str.formatTime(params.time))
        $('#td_length').html(haoutil.str.formatLength(params.len))

        if (params.hbgd) {
          $('#td_dmhb').html(haoutil.str.formatLength(params.hbgd))
        } else {
          $('#td_dmhb').html('未知')
        }

        if (params.ldgd) {
          $('#td_ldgd').html(haoutil.str.formatLength(params.ldgd))
        } else {
          $('#td_ldgd').html('未知')
        }
      }

      function addDivPoint(position) {
        //创建DIV数据图层
        var divLayer = new mars3d.layer.DivLayer()
        map.addLayer(divLayer)

        var graphic = new mars3d.graphic.DivGraphic({
          position: position,
          hasCache: false,
          style: {
            html: `<div class="divpoint divpoint-theme-29baf1">
                        <div class="divpoint-wrap">
                            <div class="area">
                                <div class="arrow-lt"></div>
                                <div class="b-t"></div>
                                <div class="b-r"></div>
                                <div class="b-b"></div>
                                <div class="b-l"></div>
                                <div class="arrow-rb"></div>
                                <div class="label-wrap">
                                    <div class="title">创业大道</div>
                                    <div class="label-content">
                                        <div class="data-li">
                                            <div class="data-label">当前位置：</div>
                                            <div class="data-value">安徽省合肥市蜀山区XX号 </div>
                                        </div>
                                        <div class="data-li">
                                            <div class="data-label">今年产值：</div>
                                            <div class="data-value"><span class="label-num">99</span><span class="label-unit">亿元</span>
                                            </div>
                                        </div>
                                        <div class="data-li">
                                            <div class="data-label">当前照片：</div>
                                            <div class="data-value"><img src="http://marsgis.cn/img/common/logo.png"> </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="b-t-l"></div>
                            <div class="b-b-r"></div>
                        </div>
                        <div class="arrow" ></div>
                    </div>`,
            scaleByDistance: new Cesium.NearFarScalar(10000, 1.0, 100000, 0.1),
          },
        })
        divLayer.addGraphic(graphic)
      }
    </script>
  </body>
</html>
